using Admin2025.Domain.Entities.App;

namespace Admin2025.Domain.DomainServices;

public class RbacDomainService
{
  // 判断用户是否对某资源有某操作权限
  public bool UserHasResourcePermission(AppUser user, string resourcePath, string permissionCode)
  {
    return user.Roles.Any(role =>
      role.Permissions.Any(permission =>
        permission.Code == permissionCode &&
        permission.Resources.Any(resource => resource.Path == resourcePath)
      )
    );
  }
}